			mui.plusReady(function(){
				plus.nativeUI.showWaiting( "城市数据加载中..." );
				var state = app.getState();
				//alert(state);
				var citydata;
				var listHTML = '';
				$.ajax({
					type:"get",
					url:"http://121.196.221.74:80/devices/addrs",
					async:true,
					headers:{'AUTHORIZATION':'token '+state.token},
					dataType:'json',
					success:function(data){
						//console.log(JSON.stringify(data));
						if(data){
							plus.nativeUI.closeWaiting();;	
							citydata = data;							
							for (var i in citydata) {				
								listHTML += '<ul class="mui-table-view "> <li class="mui-table-view-cell mui-collapse">';
								listHTML += '<a class="mui-navigate-right" href="#">' + citydata[i].text + '</a>';
								listHTML +=  '<ul class="mui-table-view mui-table-view-chevron">'
								
								for(var j in citydata[i].nodes){
									if(citydata[i].nodes[j].text=='市辖区'){
										for(var k in citydata[i].nodes[j].nodes){
											listHTML += '<li class="mui-table-view-cell">';
												listHTML += '<a class="mui-navigate-right" onclick="openDevicePage(\''+ citydata[i].nodes[j].nodes[k].text +'\')">'+ citydata[i].nodes[j].nodes[k].text +'</a>';
											listHTML += '</li>';
										}
									}else{
										listHTML += '<li class="mui-table-view-cell">';
										listHTML += '<a class="mui-navigate-right" href="#">' + citydata[i].nodes[j].text + '</a>';
										listHTML +=  '<ul class="mui-table-view mui-table-view-chevron">'
										
										for(var k in citydata[i].nodes[j].nodes){
											listHTML += '<li class="mui-table-view-cell">';
												listHTML += '<a  onclick="openDevicePage(\''+ citydata[i].nodes[j].nodes[k].text +'\')">'+ citydata[i].nodes[j].nodes[k].text +'</a>';
											listHTML += '</li>';
										}
									}									
									
									listHTML +=  '</ul>';
									listHTML += '</li>'	;				
								}
								listHTML +=  '</ul>';
								listHTML += '</li></ul>'
							}
							$('#province').append(listHTML);
						}else{
							plus.nativeUI.showWaiting( "城市数据加载中..." );;
						}
					},
					error:function(data){
						alert(JSON.stringify(data));
						
					}
				});
		
		});
				
				
			function openDevicePage(city){
				mui.openWindow({
					id: 'device_list.html',
					url: 'device_list.html',
					show: {
						aniShow: 'pop-in'
					},
					styles: {
						popGesture: 'hide'
					},
					waiting: {
						autoShow: false
					},
					extras:{
						city:city
					}
				});
			}